FROM golang:1.23 AS builder

WORKDIR /app

ENV GOPROXY=https://goproxy.cn,direct

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o netdisk-svc main.go

FROM alpine:3.18

WORKDIR /app

RUN apk add --no-cache ca-certificates tzdata

COPY --from=builder /app/netdisk-svc /app/netdisk-svc
COPY --from=builder /app/config /app/config

ENV APP_ENV=dev

# Note: EXPOSE is informational only, actual port is configured via config file
# For K8s deployment, the port is set via Helm values (config.server.port)
# For local development, use config.dev.yaml which uses port 8080
EXPOSE 80

CMD ["/app/netdisk-svc"]